# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# NOTE: This class is auto generated by the swagger code generator program.
# https://github.com/swagger-api/swagger-codegen.git
# Do not edit the class manually.

defmodule GoogleApi.CloudMonitoring.V2beta2.Api.TimeseriesDescriptors do
  @moduledoc """
  API calls for all endpoints tagged `TimeseriesDescriptors`.
  """

  alias GoogleApi.CloudMonitoring.V2beta2.Connection
  import GoogleApi.CloudMonitoring.V2beta2.RequestBuilder


  @doc """
  List the descriptors of the time series that match the metric and labels values and that have data points in the interval. Large responses are paginated; use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.

  ## Parameters

  - connection (GoogleApi.CloudMonitoring.V2beta2.Connection): Connection to server
  - project (String): The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name.
  - metric (String): Metric names are protocol-free URLs as listed in the Supported Metrics page. For example, compute.googleapis.com/instance/disk/read_ops_count.
  - youngest (String): End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp.
  - opts (KeywordList): [optional] Optional parameters
    - :alt (String): Data format for the response.
    - :fields (String): Selector specifying which fields to include in a partial response.
    - :key (String): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
    - :oauth_token (String): OAuth 2.0 token for the current user.
    - :pretty_print (Boolean): Returns response with indentations and line breaks.
    - :quota_user (String): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
    - :user_ip (String): IP address of the site where the request originates. Use this if you want to enforce per-user limits.
    - :aggregator (String): The aggregation function that will reduce the data points in each window to a single point. This parameter is only valid for non-cumulative metrics with a value type of INT64 or DOUBLE.
    - :count (Integer): Maximum number of time series descriptors per page. Used for pagination. If not specified, count &#x3D; 100.
    - :labels (List[String]): A collection of labels for the matching time series, which are represented as:   - key&#x3D;&#x3D;value: key equals the value  - key&#x3D;~value: key regex matches the value  - key!&#x3D;value: key does not equal the value  - key!~value: key regex does not match the value  For example, to list all of the time series descriptors for the region us-central1, you could specify: label&#x3D;cloud.googleapis.com%2Flocation&#x3D;~us-central1.*
    - :oldest (String): Start of the time interval (exclusive), which is expressed as an RFC 3339 timestamp. If neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest]
    - :page_token (String): The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.
    - :timespan (String): Length of the time interval to query, which is an alternative way to declare the interval: (youngest - timespan, youngest]. The timespan and oldest parameters should not be used together. Units:   - s: second  - m: minute  - h: hour  - d: day  - w: week  Examples: 2s, 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.  If neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest].
    - :window (String): The sampling window. At most one data point will be returned for each window in the requested time interval. This parameter is only valid for non-cumulative metric types. Units:   - m: minute  - h: hour  - d: day  - w: week  Examples: 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.
    - :body (ListTimeseriesDescriptorsRequest): 

  ## Returns

  {:ok, %GoogleApi.CloudMonitoring.V2beta2.Model.ListTimeseriesDescriptorsResponse{}} on success
  {:error, info} on failure
  """
  @spec cloudmonitoring_timeseries_descriptors_list(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, GoogleApi.CloudMonitoring.V2beta2.Model.ListTimeseriesDescriptorsResponse.t} | {:error, Tesla.Env.t}
  def cloudmonitoring_timeseries_descriptors_list(connection, project, metric, youngest, opts \\ []) do
    optional_params = %{
      :"alt" => :query,
      :"fields" => :query,
      :"key" => :query,
      :"oauth_token" => :query,
      :"prettyPrint" => :query,
      :"quotaUser" => :query,
      :"userIp" => :query,
      :"aggregator" => :query,
      :"count" => :query,
      :"labels" => :query,
      :"oldest" => :query,
      :"pageToken" => :query,
      :"timespan" => :query,
      :"window" => :query,
      :"body" => :body
    }
    %{}
    |> method(:get)
    |> url("/#{project}/timeseriesDescriptors/#{metric}")
    |> add_param(:query, :"youngest", youngest)
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> decode(%GoogleApi.CloudMonitoring.V2beta2.Model.ListTimeseriesDescriptorsResponse{})
  end
end
